#include <bits/stdc++.h>
#define ll long long
#define N 1010
#define endl '\n'

using namespace std;
int n,m,q;
ll arr[N][N];
ll dp[N][N];

void solve()
{
    cin>>n>>m>>q;
    for(int i = 1;i<=n;++i)
    {
        for(int j = 1;j<=m;++j)
        {
            cin>>arr[i][j];
        }
    }
    while(q--)
    {
        int x1,x2,y1,y2,k;
        cin>>x1>>y1>>x2>>y2>>k;
        dp[x1][y1]+=k;
        dp[x2+1][y2+1]+=k;
        dp[x2+1][y1]-=k;
        dp[x1][y2+1]-=k;
    }
    for(int i = 1;i<=n;++i)
    {
        for(int j = 1;j<=m;++j)
        {
            dp[i][j] += dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1];
            arr[i][j] += dp[i][j];
        }
    }
    for(int i = 1;i<=n;++i)
    {
        for(int j = 1;j<=m;++j)
        {
            cout<<arr[i][j]<<' ';
        }
        cout<<endl;
    }
}

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
    solve();
    return 0;
}
